<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

        <div class="tab-pane fade in active" id="category">
                      <div class="hero-unit"> 
                          <c:if test="${categoriesMB.getSuccess() and categoriesMB.getSuccess()}">
                              <div class="alert alert-success">
                                  <button type="button" class="close" data-dismiss="alert">x</button>
                                  Categoría creada exitosamente
                                  <script>
                                      $(document).ready(function() {
                                          $('input[type="text"]').val('');
                                      });
                                      
                                  </script>
                              </div>
                          </c:if>
                          <c:if test="${!categoriesMB.getSuccess() and categoriesMB.getSuccess()}">
                              <div class="alert alert-success">
                                  <button type="button" class="close" data-dismiss="alert">x</button>
                                  Error Inesperado creadon la nueva categoría
                              </div>
                          </c:if>
                            <h:form>
                              <div>
                                <h:outputLabel><h2>Crear una nueva Categoría</h2></h:outputLabel>
                                <h:outputLabel>Nombre de la nueva categoría</h:outputLabel>
                                <div class="input-append">
                                    <h:inputText value="#{categoriesMB.name}" class="span8" id="categoryName"/>
                                    <h:commandButton class="btn  btn-info" value="Agregar" actionListener="#{categoriesMB.createCategory}" />
                                </div>                   
                              </div>
                            </h:form>
                            <br/>
                              <div class="accordion" id="current">
                                <div class="accordion-group">
                                    <div class="accordion-heading">
                                        <a class="accordion-toggle btn" data-toggle="collapse" data-parent="#accordion2" href="#showCategories">
                                            Ver Categorías Actuales
                                        </a>
                                    </div>
                                    <div id="showCategories" class="accordion-body collapse">
                                        <div class="accordion-inner">
                                            <h:dataTable value="#{categoriesMB.categories}" var="category" cellspacing="2">
                                                 <h:column>
                                                    <h:form>  
                                                        <h:commandLink class ="links" value="#{category.name}" action="#{categoriesMB.outcome}">
                                                            <f:param name="categoryName" value="#{category.name}" />
                                                        </h:commandLink>
                                                    </h:form>  
                                                </h:column>
                                            </h:dataTable>
                                        </div>
                                    </div>
                                </div>
                              </div>  
                      </div>    
                    </div>

</html>

